package recursion

import "container/list"

func ReserveStack(stack *list.List){
	if stack.Len() == 0 {
		return
	}
	b := GetStackBottom(stack)
	ReserveStack(stack)
	stack.PushBack(b)
}

func GetStackBottom(stack *list.List) any {
	a := stack.Remove(stack.Back())
	if stack.Len() == 0 {
		return a
	} else {
		b := GetStackBottom(stack)
		stack.PushBack(a)
		return b
	}
}